<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        
        <link href="css/freepost.css" rel="stylesheet">
        
        <title>{{ title is defined ? title ~ ' - ' }}freepost</title>
    </head>
    
    <body>
        <div class="container">
        
            <div class="header">
                <div class="flex-container">
                    <div class="flex-item">
                        <a href="{{ ''|docroot }}" class="logo">
                            free
                            
                            {# &nbsp; is an extra space because "post" is displayed attached to the picture (not sure why) #}
                            <img alt="🐵&nbsp;" title="freepost" src="images/freepost.png" />
                            
                            post
                        </a>
                    </div>
                    
                    <div class="flex-item">
                        <form action="{{ 'search'|docroot }}">
                            <input type="text" name="q" value="{{ query }}" placeholder="Search posts" />
                        </form>
                    </div>
                </div>
                
                <div class="menu">
                    <a href="{{ ''|docroot }}" class="flex-item">Hot</a>
                    <a href="{{ 'new'|docroot }}" class="flex-item">New</a>
                    <a href="{{ 'about'|docroot }}" class="flex-item">About</a>

                    {% if user %}
                        {% set unread_messages = new_messages() %}
                        
                        <a href="{{ 'submit'|docroot }}" class="flex-item">Submit</a>
                        
                        {% if unread_messages %}
                            <a href="{{ 'user_activity/replies'|docroot }}" class="new_messages flex-item">
                                {{ user.name }} ({{ unread_messages }})
                            </a>
                        {% else %}
                            <a href="{{ 'user'|docroot }}" class="flex-item">
                                {{ user.name }}
                            </a>
                        {% endif %}
                        
                        <a href="{{ 'logout'|docroot }}" class="flex-item">Log out</a>
                    {% else %}
                        <a href="{{ 'login'|docroot }}" class="flex-item">Log in</a>
                    {% endif %}
                </div>
            </div>
            
            <div class="content">